<?php
if(!empty($_POST) AND !isset($_POST['Entry']))
{
	if($_POST['Cybot'] != 0) { UpdateVehicle('Cybot', $_POST['Cybot']); }
	if($_POST['Grumble'] != 0) { UpdateVehicle('Grumble', $_POST['Grumble']); }
	if($_POST['MgBike'] != 0) { UpdateVehicle('MgBike', $_POST['MgBike']); }
	if($_POST['PanzerLeicht'] != 0) { UpdateVehicle('PanzerLeicht', $_POST['PanzerLeicht']); }
	if($_POST['PanzerSchwer'] != 0) { UpdateVehicle('PanzerSchwer', $_POST['PanzerSchwer']); }
	if($_POST['Turtle'] != 0) { UpdateVehicle('Turtle', $_POST['Turtle']); }
	if($_POST['Weasel'] != 0) { UpdateVehicle('Weasel', $_POST['Weasel']); }
}
$result = RequestData('fahrzeug');
$cybot = RequestData('einheiten');
$build = RequestData('buildings');
$science = RequestData('forschung');
$ressource = RequestData('resource');
?>
<form method="post">
	<table class="buildings" style="table-layout: fixed; width: 720px;">
		<colgroup>
			<col style="width:115px;">
			<col style="width:auto;">
			<col style="width:100px">
		</colgroup>
		<thead>
			<td>Fahrzeugfabrik</td>
		</thead>
		<?php
		 $con = Connect();
		 $check = mysql_query("SELECT * FROM fahrzeug_build");
		 while($object = mysql_fetch_object($check))
		 {
			$lock = array(false, false, false, false, false, false, false);
			if($build['Fahrzeug'] >= $object->Fahrzeug_LVL)
			{
				echo '<tr><th><img src="../Game/template/Images/fahrzeug/'.$object->Name.'.png"></th>';
				echo '<th><p>'.$object->Name.'[';
				if($object->Name != "Cybot"){ echo $result[$object->Name]; }else{ echo $cybot['Cybot']; }
				echo ']</p><p>'.$object->Description.'</p>';
				echo '<p>Zeit: '.$object->Time.'</p><p>Ben&ouml;tigt: ';
				if($science['Hydraulik'] < $object->Hydraulik)
				{
					echo '<b style="color:#FF0000;"> Hydraulik Stufe '.$object->Hydraulik.'</b>,'; 
					$lock[0] = true;
				}else{
					echo '<b style="color:#00FF00;"> Hydraulik Stufe '.$object->Hydraulik.'</b>,'; 
				}
				if($science['Maschine'] < $object->Maschinbau)
				{
					echo '<b style="color:#FF0000;"> Maschinbau Stufe '.$object->Maschinbau.'</b>,'; 
					$lock[1] = true;
				}else{
					echo '<b style="color:#00FF00;"> Maschinbau Stufe '.$object->Maschinbau.'</b>';
				}
				if($object->Munition != 0)
				{
					if($science['Munition'] < $object->Munition)
					{
						echo '<b style="color:#FF0000;"> Munitions Entwicklung  Stufe '.$object->Munition.'</b>,'; 
						$lock[2] = true;
					}else{
						echo '<b style="color:#00FF00;"> Munitions Entwicklung  Stufe '.$object->Munition.'</b>,';
					}
				}
				if($science['Panzer'] < $object->Panzerung)
				{ 
					echo '<b style="color:#FF0000;"> Panzerung Entwicklung  Stufe '.$object->Panzerung.'</b></p>'; 
					$lock[3] = true;
				}else{ 
					echo '<b style="color:#00FF00;"> Panzerung Entwicklung  Stufe '.$object->Panzerung.'</b></p>'; 
				}
				echo '<p>Ressourcen: ';
				if($ressource['Credits'] < $object->Credits)
				{
					echo '<b style="color:#FF0000;">'.$object->Credits.' Credits</b>, ';
					$lock[4] = true;
				}else{
					echo '<b style="color:#00FF00;">'.$object->Credits.' Credits</b>, ';
				}
				if($ressource['Titan'] < $object->Titan)
				{
					echo '<b style="color:#FF0000;">'.$object->Titan.' Titan</b>, ';
					$lock[5] = true;
				}else{
					echo '<b style="color:#00FF00;">'.$object->Titan.' Titan</b>, ';
				}
				if($ressource['Oel'] < $object->Oel)
				{
					echo '<b style="color:#FF0000;">'.$object->Oel.' &Ouml;l</b>';
					$lock[6] = true;
				}else{
					echo '<b style="color:#00FF00;">'.$object->Oel.' &Ouml;l</b>';
				}
				if($ressource['Benzin'] < $object->Benzin)
				{
					echo ', <b style="color:#FF0000;">'.$object->Benzin.' Benzin</b></p></th>';
					$lock[7] = true;
				}else{
					echo ', <b style="color:#00FF00;">'.$object->Benzin.' Benzin</b></p></th>';
				}
				echo '<th><p>Einheiten: </p><p><input type="number" name="'.$object->Name.'" value="0" min="0" max="50" style="width:80px;" ';
				if($lock[0] == true || $lock[1] == true || $lock[2] == true || $lock[3] == true || $lock[4] == true || $lock[5] == true || $lock[6] == true || $lock[7] == true) echo 'disabled';
				echo '></p><br><p><input type="submit" name="vehicle"></p></th></tr>';
			}
		 }
		 Close($con);
		?>
	</table>
</form>